package com.youdianda.controller;

import com.youdianda.dto.YddCatePageDTO;
import com.youdianda.entity.YddCate;
import com.youdianda.result.Result;
import com.youdianda.service.YddCateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.swing.*;

@RestController
@RequestMapping("/ydd_cate")
@Api(tags = "分类管理")
@Slf4j
public class YddCateController {
    @Autowired
    private YddCateService yddCateService;

    /**
     * 查询分类详情
     * @return
     */
    @GetMapping("/rowInfo")
    @ApiOperation(value = "查询分类列表详情")
    public Result rowInfo(String id) {
        return yddCateService.rowInfo(id);
    }

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "分页查询")
    public Result list(YddCatePageDTO dto){
        log.info("分页查询"+dto);
        return yddCateService.list(dto);
    }

    /**
     * 新增分类
     * @param yddCate
     * @return
     */
    @PostMapping("/add")
    @ApiOperation(value = "新增分类")
    public Result add(@RequestBody YddCate yddCate){
        log.info("新增分类"+yddCate);
        return yddCateService.add(yddCate);
    }

    /**
     * 删除分类
     * @return
     */
    @GetMapping("/del")
    @ApiOperation(value = "删除分类")
    public Result del(String id){
        return yddCateService.del(id);
    }

    /**
     * 修改数据
     * @return
     */
    @PostMapping("update")
    @ApiOperation(value = "修改数据")
    public Result update(@RequestBody YddCate yddCate){
        return yddCateService.update(yddCate);
    }

    /**
     * 分类列表-全部
     * @param
     * @return
     */
    @GetMapping("/all")
    @ApiOperation(value = "分类列表-全部")
    public Result all(){
        return yddCateService.all();
    }

}
